﻿using System;
using System.Data;
using System.Collections.Generic;
using MxWeiXinPF.Common;
using MxWeiXinPF.Model;
namespace MxWeiXinPF.BLL
{
	/// <summary>
	/// 商品表
	/// </summary>
    public partial class wx_shop_product
    {
        private readonly MxWeiXinPF.DAL.wx_shop_product dal = new MxWeiXinPF.DAL.wx_shop_product();

        public int Add(MxWeiXinPF.Model.wx_shop_product model)
        {
            return this.dal.Add(model);
        }

        public List<MxWeiXinPF.Model.wx_shop_product> DataTableToList(DataTable dt)
        {
            List<MxWeiXinPF.Model.wx_shop_product> list = new List<MxWeiXinPF.Model.wx_shop_product>();
            int count = dt.Rows.Count;
            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    MxWeiXinPF.Model.wx_shop_product item = this.dal.DataRowToModel(dt.Rows[i]);
                    if (item != null)
                    {
                        list.Add(item);
                    }
                }
            }
            return list;
        }

        public bool Delete(int id)
        {
            return this.dal.Delete(id);
        }

        public bool DeleteList(string idlist)
        {
            return this.dal.DeleteList(idlist);
        }

        public bool Exists(int id)
        {
            return this.dal.Exists(id);
        }

        public DataSet GetAllList()
        {
            return this.GetList("");
        }

        public DataSet GetList(string strWhere)
        {
            return this.dal.GetList(strWhere);
        }

        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return this.dal.GetList(Top, strWhere, filedOrder);
        }

        public DataSet GetList(int wid, int category_id, int pageSize, int pageIndex, string strWhere, string filedOrder, out int recordCount)
        {
            return this.dal.GetList(wid, category_id, pageSize, pageIndex, strWhere, filedOrder, out recordCount);
        }

        public DataSet GetListEx(int category_id, int pageSize, int pageIndex, string strWhere, string filedOrder, out int recordCount)
        {
            return this.dal.GetListEx(category_id, pageSize, pageIndex, strWhere, filedOrder, out recordCount);
        }
        public DataSet GetList(int wid, int pageSize, int pageIndex, string strWhere, string filedOrder, out int recordCount)
        {
            return this.dal.GetList(wid, pageSize, pageIndex, strWhere, filedOrder, out recordCount);
        }

        public DataSet GetList(int top, int wid, int category_id, int pageSize, int pageIndex, string strWhere, string filedOrder, out int recordCount)
        {
            return this.dal.GetList(top, wid, category_id, pageSize, pageIndex, strWhere, filedOrder, out recordCount);
        }

        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            return this.dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
        }

        public DataSet GetListForImport(string strWhere)
        {
            return this.dal.GetListForImport(strWhere);
        }

        public DataSet GetListForStock(int wid, int category_id, int pageSize, int pageIndex, string strWhere, string filedOrder, out int recordCount)
        {
            return this.dal.GetListForStock(wid, category_id, pageSize, pageIndex, strWhere, filedOrder, out recordCount);
        }

        public int GetMaxId()
        {
            return this.dal.GetMaxId();
        }

        public int GetMaxIdByCode(string code)
        {
            return this.dal.GetMaxIDByCode(code);
        }

        public MxWeiXinPF.Model.wx_shop_product GetModel(int id)
        {
            MxWeiXinPF.Model.wx_shop_product model = new MxWeiXinPF.Model.wx_shop_product();
            model = this.dal.GetModel(id);
            model.albums = new MxWeiXinPF.BLL.wx_shop_albums().GetModelList("productId=" + id);
            model.attrs = new MxWeiXinPF.DAL.wx_shop_productAttr_value().GetAttrModelList(id);
            model.skulist = new MxWeiXinPF.DAL.wx_shop_sku().GetpSkuModelList(id);
            return model;
        }

        public List<MxWeiXinPF.Model.wx_shop_product> GetModelList(string strWhere)
        {
            DataSet list = this.dal.GetList(strWhere);
            return this.DataTableToList(list.Tables[0]);
        }

        public int GetRecordCount(string strWhere)
        {
            return this.dal.GetRecordCount(strWhere);
        }

        public bool Update(MxWeiXinPF.Model.wx_shop_product model)
        {
            return this.dal.Update(model);
        }

        public void UpdateField(int id, string strValue)
        {
            this.dal.UpdateField(id, strValue);
        }

        public DataSet getProductNumberbyShopID(int wid, int shopid)
        {
            return dal.getProductNumberbyShopID(wid, shopid);
        }
    }
}

